#include "qaddformdialog.h"
#include "ui_qaddformdialog.h"

#include "../../lib/corelib/qnamevalidator.h"

QAddFormDialog::QAddFormDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::QAddFormDialog),
    m_ret(0),
    m_nameEdit(new QNameEdit(this))
{
    ui->setupUi(this);
    m_nameEdit->setGeometry(110,20,170,20);
    m_nameEdit->setFocus();
    m_nameEdit->setValue("");
}

QAddFormDialog::~QAddFormDialog()
{
    delete ui;
}

void QAddFormDialog::on_okBtn_clicked()
{
    QString name=m_nameEdit->value();
    if(name=="")
    {
        return;
    }
    m_ret=1;
    close();
}

void QAddFormDialog::on_cancleBtn_clicked()
{
    close();
}

int QAddFormDialog::exec()
{
    QDialog::exec();
    return m_ret;
}

QString QAddFormDialog::getFormName()
{
    return m_nameEdit->value();
}

void QAddFormDialog::setPageNames(QStringList names)
{
    m_nameEdit->setIntermediateList(names);
}

QString QAddFormDialog::getFormType()
{
    return ui->page->isChecked()?"Page":"Widget";
}
